﻿using UnityEngine;
using UnityEngine.UI;
using ProtoBuf.Message;

namespace AutoChess
{
    public class ChessFightRecordWave : MonoBehaviour
    {
        [SerializeField]
        private Text mWaveNum;
        [SerializeField]
        private GameObject mFightRecordItemObj;
        [SerializeField]
        private GridLayoutGroup mGrid;

        public void Init(AutoChessFightRecordWaveInfo data)
        {
            mWaveNum.text = string.Format(TableTextBlo.GetText("ACFightRecordWave"), data.wave);
            mFightRecordItemObj.SetActive(false);
            mGrid.transform.DestroyChildren();
            foreach (var item in data.autoChessFightRecordInfos)
            {
                GameObject go = Instantiate<GameObject>(mFightRecordItemObj, mGrid.transform);
                go.transform.localPosition = Vector3.zero;
                go.transform.localScale = Vector3.one;
                go.SetActive(true);
                go.GetComponent<ChessFightRecordItem>().Init(item);
            }
        }
    }
}